package org.example.Server.controller.resource;


import lombok.extern.slf4j.Slf4j;
import org.example.Server.model.resource.StuResource;
import org.example.Server.service.resource.ResourceService;
import org.example.Server.utils.ResultAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学生收藏资源：图片、视频、ppt等
 */
@RestController
@Slf4j
@RequestMapping("/youxich/resource/stu")
public class StuResourceController {
    @Autowired
    ResourceService resourceService;

    /**
     * 学生收藏资源
     *
     * @param stuResource
     * @return
     */
    @PostMapping
    public ResultAPI addResource(@RequestBody StuResource stuResource) {
        return resourceService.addStuResource(stuResource);
    }

    /**
     * 获取学生的收藏资源
     *
     * @param userId
     * @param resourceType
     * @return
     */
    @GetMapping
    public ResultAPI getResourceList(@RequestParam Integer userId, @RequestParam String resourceType) {
        return resourceService.getResourceList(userId, resourceType);
    }

    /**
     * 学生移除收藏资源
     * @param ids
     * @return
     */
    @DeleteMapping("{ids}")
    public ResultAPI deleteStuResource(@PathVariable List<Integer> ids) {
        return resourceService.deleteStuResource(ids);
    }
}
